package com.ruoyi.livesass.api.service;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.ruoyi.livesass.api.mapper.LbsAliyunAmountSplitMapper;
import com.ruoyi.livesass.api.domain.LbsAliyunAmountSplit;
import com.ruoyi.livesass.api.pojo.query.LbsAliyunAmountSplitQuery;

/**
 * 阿里云资源子系统拆分表Service业务层处理
 *
 *
 * @author ydb
 */
@Service
public class LbsAliyunAmountSplitService {
    @Autowired
    private LbsAliyunAmountSplitMapper lbsAliyunAmountSplitMapper;

    /**
     * 查询阿里云资源子系统拆分表
     *
     * @param id 阿里云资源子系统拆分表主键
     * @return 阿里云资源子系统拆分表
     */
    public LbsAliyunAmountSplit selectById(String id) {
        return lbsAliyunAmountSplitMapper.selectById(id);
    }

    /**
     * 查询阿里云资源子系统拆分表列表
     *
     * @param query 查询条件
     * @param page 分页条件
     * @return 阿里云资源子系统拆分表
     */
    public List<LbsAliyunAmountSplit> selectList(LbsAliyunAmountSplitQuery query, Pageable page) {
        if (page != null) {
            PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
        }
        QueryWrapper<LbsAliyunAmountSplit> qw = new QueryWrapper<>();
        qw.eq("del_flag",0);
        String createDept = query.getCreateDept();
        if (!StringUtils.isEmpty(createDept)) {
            qw.eq("create_dept", createDept);
        }
        String updateIp = query.getUpdateIp();
        if (!StringUtils.isEmpty(updateIp)) {
            qw.eq("update_ip", updateIp);
        }
        Integer version = query.getVersion();
        if (version != null) {
            qw.eq("version", version);
        }
        String resourceType = query.getResourceType();
        if (!StringUtils.isEmpty(resourceType)) {
            qw.eq("resource_type", resourceType);
        }
        String domain = query.getDomain();
        if (!StringUtils.isEmpty(domain)) {
            qw.eq("domain", domain);
        }
        String xtmc = query.getXtmc();
        if (!StringUtils.isEmpty(xtmc)) {
            qw.eq("xtmc", xtmc);
        }
        BigDecimal ftbl = query.getFtbl();
        if (ftbl != null) {
            qw.eq("ftbl", ftbl);
        }
        BigDecimal mount = query.getMount();
        if (mount != null) {
            qw.eq("mount", mount);
        }
        BigDecimal pretaxAmount = query.getPretaxAmount();
        if (pretaxAmount != null) {
            qw.eq("pretax_amount", pretaxAmount);
        }
        BigDecimal pretaxGrossAmount = query.getPretaxGrossAmount();
        if (pretaxGrossAmount != null) {
            qw.eq("pretax_gross_amount", pretaxGrossAmount);
        }
        String gsrq = query.getGsrq();
        if (!StringUtils.isEmpty(gsrq)) {
            qw.eq("gsrq", gsrq);
        }
        Long wafCount = query.getWafCount();
        if (wafCount != null) {
            qw.eq("waf_count", wafCount);
        }
        Long wafMaxPv = query.getWafMaxPv();
        if (wafMaxPv != null) {
            qw.eq("waf_max_pv", wafMaxPv);
        }
        Long wafInBytes = query.getWafInBytes();
        if (wafInBytes != null) {
            qw.eq("waf_in_bytes", wafInBytes);
        }
        Long wafOutBytes = query.getWafOutBytes();
        if (wafOutBytes != null) {
            qw.eq("waf_out_bytes", wafOutBytes);
        }
        BigDecimal slbAmount = query.getSlbAmount();
        if (slbAmount != null) {
            qw.eq("slb_amount", slbAmount);
        }
        BigDecimal slbGrossAmount = query.getSlbGrossAmount();
        if (slbGrossAmount != null) {
            qw.eq("slb_gross_amount", slbGrossAmount);
        }
        BigDecimal dbAmount = query.getDbAmount();
        if (dbAmount != null) {
            qw.eq("db_amount", dbAmount);
        }
        BigDecimal dbGrossAmount = query.getDbGrossAmount();
        if (dbGrossAmount != null) {
            qw.eq("db_gross_amount", dbGrossAmount);
        }
        BigDecimal dbBakAmount = query.getDbBakAmount();
        if (dbBakAmount != null) {
            qw.eq("db_bak_amount", dbBakAmount);
        }
        BigDecimal dbBakGrossAmount = query.getDbBakGrossAmount();
        if (dbBakGrossAmount != null) {
            qw.eq("db_bak_gross_amount", dbBakGrossAmount);
        }
        BigDecimal domainAmount = query.getDomainAmount();
        if (domainAmount != null) {
            qw.eq("domain_amount", domainAmount);
        }
        BigDecimal domainGrossAmount = query.getDomainGrossAmount();
        if (domainGrossAmount != null) {
            qw.eq("domain_gross_amount", domainGrossAmount);
        }
        BigDecimal nasAmount = query.getNasAmount();
        if (nasAmount != null) {
            qw.eq("nas_amount", nasAmount);
        }
        BigDecimal nasGrossAmount = query.getNasGrossAmount();
        if (nasGrossAmount != null) {
            qw.eq("nas_gross_amount", nasGrossAmount);
        }
        BigDecimal redisAmount = query.getRedisAmount();
        if (redisAmount != null) {
            qw.eq("redis_amount", redisAmount);
        }
        BigDecimal redisGrossAmount = query.getRedisGrossAmount();
        if (redisGrossAmount != null) {
            qw.eq("redis_gross_amount", redisGrossAmount);
        }
        BigDecimal casAmount = query.getCasAmount();
        if (casAmount != null) {
            qw.eq("cas_amount", casAmount);
        }
        BigDecimal casGrossAmount = query.getCasGrossAmount();
        if (casGrossAmount != null) {
            qw.eq("cas_gross_amount", casGrossAmount);
        }
        BigDecimal cdtAmount = query.getCdtAmount();
        if (cdtAmount != null) {
            qw.eq("cdt_amount", cdtAmount);
        }
        BigDecimal cdtGrossAmount = query.getCdtGrossAmount();
        if (cdtGrossAmount != null) {
            qw.eq("cdt_gross_amount", cdtGrossAmount);
        }
        BigDecimal natAmount = query.getNatAmount();
        if (natAmount != null) {
            qw.eq("nat_amount", natAmount);
        }
        BigDecimal natGrossAmount = query.getNatGrossAmount();
        if (natGrossAmount != null) {
            qw.eq("nat_gross_amount", natGrossAmount);
        }
        BigDecimal eipAmount = query.getEipAmount();
        if (eipAmount != null) {
            qw.eq("eip_amount", eipAmount);
        }
        BigDecimal eipGrossAmount = query.getEipGrossAmount();
        if (eipGrossAmount != null) {
            qw.eq("eip_gross_amount", eipGrossAmount);
        }
        BigDecimal saeAmount = query.getSaeAmount();
        if (saeAmount != null) {
            qw.eq("sae_amount", saeAmount);
        }
        BigDecimal saeGrossAmount = query.getSaeGrossAmount();
        if (saeGrossAmount != null) {
            qw.eq("sae_gross_amount", saeGrossAmount);
        }
        BigDecimal cdnAmount = query.getCdnAmount();
        if (cdnAmount != null) {
            qw.eq("cdn_amount", cdnAmount);
        }
        BigDecimal cdnGrossAmount = query.getCdnGrossAmount();
        if (cdnGrossAmount != null) {
            qw.eq("cdn_gross_amount", cdnGrossAmount);
        }
        BigDecimal ecsAmount = query.getEcsAmount();
        if (ecsAmount != null) {
            qw.eq("ecs_amount", ecsAmount);
        }
        BigDecimal ecsGrossAmount = query.getEcsGrossAmount();
        if (ecsGrossAmount != null) {
            qw.eq("ecs_gross_amount", ecsGrossAmount);
        }
        BigDecimal wafAmount = query.getWafAmount();
        if (wafAmount != null) {
            qw.eq("waf_amount", wafAmount);
        }
        BigDecimal wafGrossAmount = query.getWafGrossAmount();
        if (wafGrossAmount != null) {
            qw.eq("waf_gross_amount", wafGrossAmount);
        }
        BigDecimal ossAmount = query.getOssAmount();
        if (ossAmount != null) {
            qw.eq("oss_amount", ossAmount);
        }
        BigDecimal ossGrossAmount = query.getOssGrossAmount();
        if (ossGrossAmount != null) {
            qw.eq("oss_gross_amount", ossGrossAmount);
        }
        BigDecimal smsAmount = query.getSmsAmount();
        if (smsAmount != null) {
            qw.eq("sms_amount", smsAmount);
        }
        BigDecimal smsGrossAmount = query.getSmsGrossAmount();
        if (smsGrossAmount != null) {
            qw.eq("sms_gross_amount", smsGrossAmount);
        }
        return lbsAliyunAmountSplitMapper.selectList(qw);
    }

    /**
     * 新增阿里云资源子系统拆分表
     *
     * @param lbsAliyunAmountSplit 阿里云资源子系统拆分表
     * @return 结果
     */
    public int insert(LbsAliyunAmountSplit lbsAliyunAmountSplit) {
        lbsAliyunAmountSplit.setDelFlag("0");
        lbsAliyunAmountSplit.setCreateTime(LocalDateTime.now());
        return lbsAliyunAmountSplitMapper.insert(lbsAliyunAmountSplit);
    }

    /**
     * 修改阿里云资源子系统拆分表
     *
     * @param lbsAliyunAmountSplit 阿里云资源子系统拆分表
     * @return 结果
     */
    public int update(LbsAliyunAmountSplit lbsAliyunAmountSplit) {
        return lbsAliyunAmountSplitMapper.updateById(lbsAliyunAmountSplit);
    }

    /**
     * 批量删除阿里云资源子系统拆分表
     *
     * @param ids 需要删除的阿里云资源子系统拆分表主键
     * @return 结果
     */
    public int deleteByIds(String[] ids) {
        return lbsAliyunAmountSplitMapper.updateDelFlagByIds(ids);
    }

    /**
     * 删除阿里云资源子系统拆分表信息
     *
     * @param id 阿里云资源子系统拆分表主键
     * @return 结果
     */
    public int deleteById(String id) {
        String[] ids = {id};
        return lbsAliyunAmountSplitMapper.updateDelFlagByIds(ids);
    }
}
